<template>
	<view class="container">
		<!-- <view class="list-cell b-b m-t" @click="navTo('个人资料')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">个人资料</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		<view class="list-cell b-b" @click="navTo('../address/address')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">{{ i18n.set.address }}</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<!-- <view class="list-cell" @click="navTo('实名认证')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">实名认证</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->

		<view class="list-cell m-t">
			<text class="cell-tit">{{ i18n.set.mespush }}</text>
			<switch checked color="#fa436a" @change="switchChange" />
		</view>
		<!-- <view class="list-cell m-t b-b" @click="clearcache" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">清除缓存</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		<view class="list-cell b-b" @click="navTo('关于River Mall')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">{{ i18n.set.about }}River Mall</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell">
			<text class="cell-tit">{{ i18n.set.update }}</text>
			<text class="cell-tip">{{ i18n.set.recentversion }} 1.0.3</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell log-out-btn" @click="toLogout">
			<text class="cell-tit">{{ i18n.set.logout }}</text>
		</view>
	</view>
</template>

<script>
import {
    mapMutations,
	mapState
} from 'vuex';
export default {
	data() {
		return {

		};
	},
	computed:{
		   i18n() {
		     return this.$i18nMsg()
		   }
		},
		onLoad() {
			let title=this.$i18nMsg().pages.set;
			uni.setNavigationBarTitle({
				title
			});
		},
	methods:{
		...mapMutations(['hasLogin','userInfo','logout']),

		navTo(url){
			if(!this.hasLogin){
				url = '/pages/public/login';
			}
			uni.navigateTo({
				url
			})
		},
		//退出登录
		toLogout(){
			uni.showModal({
			    content: this.$i18nMsg().set.confirmlogout,
			    success: (e)=>{
			    	if(e.confirm){
			    		this.logout();
			    		setTimeout(()=>{
			    			uni.navigateBack();
			    		}, 200)
			    	}
			    }
			});
		},
		//switch
		switchChange(e){
			let statusTip = e.detail.value ? this.$i18nMsg().set.open: this.$i18nMsg().set.close;
			//this.$api.msg(`${statusTip}this.$i18nMsg().set.mespush`);
			uni.showToast({
				title: statusTip+this.$i18nMsg().set.mespush,
			});
		},
		clearcache(){
			try {
			uni.clearStorageSync();
			} catch (e) {
			// error
			}
		}
	}
}
</script>

<style lang="scss">
page {
	background: $page-color-base;
}
.list-cell {
	display: flex;
	align-items: baseline;
	padding: 20upx $page-row-spacing;
	line-height: 60upx;
	position: relative;
	background: #fff;
	justify-content: center;
	&.log-out-btn {
		margin-top: 40upx;
		.cell-tit {
			color: $uni-color-primary;
			text-align: center;
			margin-right: 0;
		}
	}
	&.cell-hover {
		background: #fafafa;
	}
	&.b-b:after {
		left: 30upx;
	}
	&.m-t {
		margin-top: 16upx;
	}
	.cell-more {
		align-self: baseline;
		font-size: $font-lg;
		color: $font-color-light;
		margin-left: 10upx;
	}
	.cell-tit {
		flex: 1;
		font-size: $font-base + 2upx;
		color: $font-color-dark;
		margin-right: 10upx;
	}
	.cell-tip {
		font-size: $font-base;
		color: $font-color-light;
	}
	switch {
		transform: translateX(16upx) scale(0.84);
	}
}
</style>
